//
//  YYSubscribeView.m
//  drivingSchool
//
//  Created by 子yu 刘 on 2018/11/20.
//  Copyright © 2018年 子yu 刘. All rights reserved.
//

#import "YYSubscribeView.h"

@implementation YYSubscribeView

+ (YYSubscribeView *)sharedInstance{
    static  YYSubscribeView * pullView;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        pullView = [[YYSubscribeView alloc] init];
    });
    return pullView;
}


- (instancetype)init{
    if (self = [super init]) {
        self = [[[NSBundle mainBundle] loadNibNamed:@"YYSubscribeView" owner:self options:nil] firstObject];
        self.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH(), DEF_SCREEN_HEIGHT());
    }
    return self;
}

+ (void)show{
    [[YYSubscribeView sharedInstance] show];
}

- (void)show{
    // [self.tableView reloadData];
    [DEF_WINDOW addSubview:self];
}


- (IBAction)cha:(id)sender {
    [self removeFromSuperview];
}


- (IBAction)corfirme:(id)sender {
    if (self.tfName.text.length == 0) {
        [AlertUtil alertMessage:@"请输入真实姓名"];
        return;
    }
    if (self.tfPhone.text.length != 11) {
        [AlertUtil alertMessage:@"请输入正确的手机号码"];
        return;
    }
    
    [RequestOperationManager seeCar_name:self.tfName.text iphone:self.tfPhone.text vehicle_id:self.vehicle_id seller_id:self.seller_id success:^(id result) {
        if (DEF_REQ_SUCCESS) {
            [AlertUtil alertMessage:@"预约成功"];
            [GCDUtil gcd_runAfterDelay:1 InMainQueue:^{
                 [self removeFromSuperview];
            }];
           
        }else{
             [AlertUtil alertMessage:@"预约失败"];
        }
        
        
    } failture:^(NSError *error) {
        
    }];
    
  //
}

@end
